Systems that perform parallel processing comprise simultaneously executing processes. A common problem when using parallel processing is protecting the contents of a common resource.
One known way to implement this is to use a semaphore, which is generally a hardware or software flag. In multitasking systems, a semaphore is a variable that indicates the status of a common resource. It is used to lock the resource that is being used. A process needing the resource checks the semaphore to determine the resource's status and then decides how to proceed. A semaphore indicates to other potential users that a file or other resource is in use and prevents access by more than one process.
However, when multiple processes need access to a common resource, problems such as starvation and/or deadlock may occur. Starvation occurs when one or more processes are prevented from accessing the common resource, and deadlock may occur when one or more processes lock each other, thereby stopping execution.
This is further complicated when there are multiple resources. The classical approach to solving this problem is to implement a semaphore for each resource. However, when the number of resources becomes very large, this solution is not very effective.